package com.our.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.our.biz.InvestTypesBiz;
import com.our.biz.SearchBiz;
import com.our.model.InvestTypes;
import com.our.model.Invests;
import com.our.model.UserPro;
import com.our.model.userTiXian;


@Controller
@RequestMapping("/search")
public class SearchController {
	@Resource
	private InvestTypesBiz itBiz;
	@Resource
	private SearchBiz sBiz;
	
	@RequestMapping("/searchInvestType")
	public String findType(Map<String, Object> request){
		try {
			List<InvestTypes> list = itBiz.findAll();	
			request.put("list", list);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "search/search";
	}
	@RequestMapping("/search1")
	public String findByTypeIdAndPeriods(int investTypeId, int proPeriods,Map<String, Object> request){
		try {
			List<InvestTypes> list = itBiz.findAll();	
			request.put("list", list);
			List<Invests> infolist = sBiz.findByTypeIdAndPeriods(investTypeId, proPeriods);
			request.put("infoList", infolist);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "search/search1";	
	}
	@RequestMapping("/search2")
	public String findByUserName(String userName,Map<String, Object> request){
		try {
			List<InvestTypes> list = itBiz.findAll();	
			request.put("list", list);
			List<userTiXian> userList = sBiz.findByuserName(userName);
			request.put("userList", userList);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "search/search2";
	}
	@RequestMapping("/search3")
	public String findInvestByUserName(String userName,Map<String, Object> request){
		try {
			List<InvestTypes> list = itBiz.findAll();	
			request.put("list", list);
			List<UserPro> userProList = sBiz.findInvestByUserName(userName);
			request.put("userProList", userProList);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "search/search3";
	}
	
}
